package com.trkj.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;


@Slf4j
@Aspect
@Component
public class LogAspect {
    @Pointcut(value = "execution(* com.trkj.service..*.*(..))")
    public void pointcut(){}
    @Before(value = "pointcut()")
    public void beforeAdvice(JoinPoint joinPoint){
        log.debug(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>即将进入到{}类的{}方法",
                joinPoint.getTarget().getClass().getName(),
                joinPoint.getSignature());
    }
    @After(value = "pointcut()")
    public void afterAdvice(JoinPoint joinPoint){
        log.debug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<完成{}类的{}方法的执行",
                joinPoint.getTarget().getClass().getName(),
                joinPoint.getSignature());
    }
    /*@Around(value = "pointcut()")
    public Object aroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable {
        log.debug("开始环绕");
        Object obj=joinPoint.proceed();
        log.debug("完成环绕");
        return obj;
    }*/
}
